<template>
    <a-descriptions title="订单详细">
        <a-descriptions-item label="订单编号">{{orderData['orderid']}}</a-descriptions-item>
        <a-descriptions-item label="用户名">{{orderData['username']}}</a-descriptions-item>
        <a-descriptions-item label="订单金额">￥{{orderData['money']}}元</a-descriptions-item>
        <a-descriptions-item label="订单类型">{{orderData['typename']}}</a-descriptions-item>
        <a-descriptions-item label="订单状态">{{orderData['statusname']}}</a-descriptions-item>
        <a-descriptions-item label="支付状态">{{orderData['paystatusname']}}</a-descriptions-item>
    </a-descriptions>
     
</template>
<script>
import { defineComponent,reactive,watch } from 'vue';
import { orderInfo } from '@/api/order';
import { useRoute } from 'vue-router';
import { message } from 'ant-design-vue';


export default defineComponent({
    emits:["updataList"],
    setup(props,context) {
        const orderData = reactive({ orderid: "", username: "", userid: 0, money: 0, type: "", status: 0, paystatus: 0, content: "" });
        const route = useRoute();
        let orderid = route.params["orderid"];
        watch(() => route.params["orderid"], () => {
            orderid = route.params["orderid"];
            getOrderInfo();
        });
         
        const getOrderInfo = () => {
            if (orderid == undefined || !orderid) {
                message.error("页面参数错误");
            }
            else {
                orderInfo({ orderid: orderid }).then(res => {
                    if (res.data["code"] == 200) {
                        Object.assign(orderData, res.data["data"]);
                    }
                    else {
                        message.error(res.data["msg"]);
                        context.emit("updataList");
                        
                    }
                }, err => {
                    console.log(err);
                });
            }
        };

        getOrderInfo();

        return {
            orderData
        };
    },
    components: { }
})
</script>
